package day10.FileTest;

import java.io.File;

public class Test4 {
    public static void main(String[] args) {
        File dir = new File("/Users/hao/Desktop");
        /*
        如果目录不存在，或目录无权访问
        会得到null值
         */
        String[] names = dir.list();
        File[] files = dir.listFiles();

        for (String n: names) {
            System.out.println(n);
        }
        for (File file: files) {
            System.out.println(file.getName() +"-"+ file.length());
        }
    }
}
